package org.lvgo.adapter.object.demo2;

/**
 * @author lvgo
 * @version 1.0
 * @description: 多媒体播放适配器
 * @date 18-8-21 上午11:55
 */
public class MediaPlayerAdapter implements MediaPlayer {

    private AdvancedMediaPlayer advancedMediaPlayer;

    public MediaPlayerAdapter(String audioType) {
        if (audioType.equalsIgnoreCase(AudioType.AVI)) {
            advancedMediaPlayer = new AviPlayer();
        } else if (audioType.equalsIgnoreCase(AudioType.MP4)) {
            advancedMediaPlayer = new Mp4Player();
        }
    }

    /**
     * 播放
     *
     * @param audioType 音频类型
     * @param fileName  文件名称
     */
    @Override
    public void play(String audioType, String fileName) {
        if (audioType.equalsIgnoreCase(AudioType.AVI)) {
            advancedMediaPlayer.playAvi(fileName);
        } else if (audioType.equalsIgnoreCase(AudioType.MP4)) {
            advancedMediaPlayer.playMp4(fileName);
        }
    }
}
